import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.Timer;


public class Star extends JLabel implements ActionListener {

	JLabel star;
	Timer timer;
	double pointX[]=new double[360];
	double pointY[]=new double[360];
	int w=40,h=40,i=0;
	Star(){
		setLayout(new FlowLayout());
		setPreferredSize(new Dimension(w,h));
		timer=new Timer(30,this);
		setIcon(new ImageIcon("moon.jpg"));
		setHorizontalAlignment(SwingConstants.CENTER);
		star=new JLabel(new ImageIcon("star.jpg"),SwingConstants.CENTER);
		add(star);
		star.setPreferredSize(new Dimension(20,20));
		pointX[0]=0;
		pointY[0]=h/2;
		double angle=1*Math.PI/180;
		for(int i=0;i<359;i++){
			pointX[i+1]=pointX[i]*Math.cos(angle)-Math.sin(angle)*pointY[i];
			pointY[i+1]=pointY[i]*Math.cos(angle)+pointX[i]*Math.sin(angle);
		}
		for(int i=0;i<360;i++){
			pointX[i]=0.8*pointX[i]+w/2;
			pointY[i]=0.8*pointY[i]+h/2;
		}
		timer.start();
	}

		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			i=(i+1)%360;
			star.setLocation((int)pointX[i],(int)pointY[i]+10);
		

		}

}
